Python is a high-level, general-purpose programming language. It's designed to be easy to read and write, which makes it a great starting point for beginners. It's used in web development, data analysis, artificial intelligence, and more.
print("Hello, World!")
This code prints the text "Hello, World!" to the screen. The print() function is used to display output.
name = "Alice"
age = 25
x = 5
y = 3
sum = x + y # Addition
diff = x - y # Subtraction
prod = x * y # Multiplication
quot = x / y # Division
age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
# For loop example
for i in range(5):
print(i) # Prints numbers 0 to 4
# While loop example
count = 0
while count < 5:
print(count)
count += 1
def greet(name):
print("Hello, " + name + "!")
greet("Alice") # Output: Hello, Alice!
You can install libraries using pip, the Python package manager:
pip install numpy
Once you're comfortable with the basics, you can explore more advanced topics like: